import javafx.scene.paint.Color;

public enum PieceType {
    I(new int[][] {
        {0, 0, 0, 0},
        {1, 1, 1, 1},
        {0, 0, 0, 0},
        {0, 0, 0, 0}
    }, Color.CYAN),
    
    J(new int[][] {
        {1, 0, 0},
        {1, 1, 1},
        {0, 0, 0}
    }, Color.BLUE),
    
    L(new int[][] {
        {0, 0, 1},
        {1, 1, 1},
        {0, 0, 0}
    }, Color.ORANGE),
    
    O(new int[][] {
        {1, 1},
        {1, 1}
    }, Color.YELLOW),
    
    S(new int[][] {
        {0, 1, 1},
        {1, 1, 0},
        {0, 0, 0}
    }, Color.GREEN),
    
    T(new int[][] {
        {0, 1, 0},
        {1, 1, 1},
        {0, 0, 0}
    }, Color.PURPLE),
    
    Z(new int[][] {
        {1, 1, 0},
        {0, 1, 1},
        {0, 0, 0}
    }, Color.RED);
    
    private final int[][] shape;
    private final Color color;
    
    PieceType(int[][] shape, Color color) {
        this.shape = shape;
        this.color = color;
    }
    
    public int[][] getShape() {
        // 返回形状的深拷贝，防止修改原始数据
        int[][] copy = new int[shape.length][];
        for (int i = 0; i < shape.length; i++) {
            copy[i] = shape[i].clone();
        }
        return copy;
    }
    
    public Color getColor() {
        return color;
    }
}
